<?php
/********************************************************
 *
 * 此文件的作用:
 *		所有家教业务的操作
 *
 * @copyright Copyright (c) 2007-2008
 * @author 刘昌功 lcg635@126.com
 *
 ********************************************************/
defined('APP_DIR') or die('404 Not Found');

FLEA::loadClass('Common_Model');

class Model_FamilyEdu extends Common_Model {
	function __construct() {
		parent::Common_Model();
		$this->_tb = FLEA::getSingleton('Table_FamilyEdu');
	}
	
	function getNewFamilyEdus() {
		return $this->_tb->getList();
	}

	function getList($page = 0, $pageSize = 15, $pagerData = true) {
		FLEA::loadHelper('pager');

		$fields = 'title, finish, registrant, charge, created, familyEdu_id';
		$cond = null;

		$pager = new FLEA_Helper_Pager($this->_tb, $page, $pageSize, $cond, 'created desc');
		$lists = $pager->findAll($fields);
		foreach ($lists as $k => $v)
			$lists[$k]['charge'] = 1 == $v['charge'] ? '完成' : '未完成';

		$viewData['lists'] = $lists;
		if ( true == $pagerData )
			$viewData['pagerData'] = $pager->getPagerData();
		return $viewData;
	}

	function getInfo($familyEdu_id) {
		$this->_tb->enableLink('householder');
		$result = $this->_tb->find('familyEdu_id = ' . $familyEdu_id);
		return $result;
	}

	function insert($row) {
		$resutl = $this->_tb->create($row);
		return $result;
	}

	function update($row) {
		$resutl = $this->_tb->update($row);
		return $result;
	}

	function delete($nid) {
		$resutl = $this->_tb->removeByPkv($nid);
		return $result;
	}

	function getForm($data = null) {
		return $this->_tb->form($data);
	}
}